package com.information.manage.base.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.information.manage.base.model.entity.Gongqu;
import com.information.manage.base.model.query.PageQuery;
import com.information.manage.base.sevice.GongquService;
import com.information.manage.basic.common.result.Result;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/phm/base/gongqu/")
public class GongquController {


    @Resource
    private GongquService gongquService;

    @GetMapping("list")
    public Result<List<Gongqu>> list() {
        return Result.ok(gongquService.list());
    }

    @GetMapping("page")
    public Result<Page<Gongqu>> getGongquPage(PageQuery pageQuery){
        return Result.ok(gongquService.getgongquByPage(pageQuery));
    }

    @GetMapping("find/{id}")
    public Result<Gongqu> findGongquById(@PathVariable Integer id){
        return Result.ok(gongquService.getById(id));
    }

    @PostMapping("add")
    public Result<Boolean> addGongqu(@RequestBody Gongqu gongqu){
        return Result.ok(gongquService.save(gongqu));
    }

    @PostMapping("update")
    public Result<Integer> updateGongqu(@RequestBody Gongqu gongqu){
        return gongquService.updateGongqu(gongqu);
    }
}
